package com.cwb.controller;

import com.cwb.pojo.User;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Author 27435
 * @Date 2024/12/2318:25
 * @Version 1.0
 */

@Controller
public class HelloController {

    @RequestMapping("/save")
    @ResponseBody
    public String save(String name, String age){
        System.out.println("name:" + name);
        System.out.println("age:" + age);
        return "save~~~~~~~~";
    }

    @RequestMapping("/user")
    @ResponseBody
    public String user(User user){
        System.out.println(user);
        return "user~~~~~~~~";
    }

    @RequestMapping("/arr")
    @ResponseBody
    public String arr(String[] likes){
        System.out.println(Arrays.toString(likes));
        return "arr~~~~~~~~";
    }

    @RequestMapping("/list")
    @ResponseBody
    public String list(@RequestParam("likes") List<String> likes){
        System.out.println(likes);
        return "list~~~~~~~~";
    }

    @RequestMapping("/map")
    @ResponseBody
    public String map(@RequestParam Map<String,String> maps){
        System.out.println(maps);
        return "map~~~~~~~~";
    }

    @RequestMapping("/date")
    @ResponseBody
    public String date(Date date,
                       @DateTimeFormat(pattern = "yyyy-MM-dd") Date date1,
                       @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date date2){
        System.out.println("date:" + date);
        System.out.println("date1:" + date1);
        System.out.println("date2:" + date2);
        return "date~~~~~~~~";
    }

}
